package com.kodcu.web.training.leftmenupanel;

import com.kodcu.web.training.TrainingPage;
import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;

public class LeftMenuPanel extends Panel {

    public LeftMenuPanel(String id, PageParameters params) {
        super(id);


        PageParameters paramsBilgi = new PageParameters();
        paramsBilgi.add("0", "java-egitimleri"); // java egitimi
        WebMarkupContainer markUpBilgi = new WebMarkupContainer("MarkUpBilgi");
        markUpBilgi.setOutputMarkupId(true);
        BookmarkablePageLink bilgiBaglantisi =
                new BookmarkablePageLink("Bilgi", TrainingPage.class, paramsBilgi);
        markUpBilgi.add(bilgiBaglantisi);


        PageParameters paramsKayit = new PageParameters();
        paramsKayit.add("0", "kodcu-com-java-egitimlerine-kayit"); // SSS
        WebMarkupContainer markUpKayit = new WebMarkupContainer("markUpKayit");
        markUpKayit.setOutputMarkupId(true);
        BookmarkablePageLink kayit =
                new BookmarkablePageLink("Kayit", TrainingPage.class, paramsKayit);
        markUpKayit.add(kayit);


        PageParameters paramsEgitmen = new PageParameters();
        paramsEgitmen.add("0", "java-egitmenler");
        WebMarkupContainer markUpEgitmen = new WebMarkupContainer("markUpEgitmen");
        markUpEgitmen.setOutputMarkupId(true);
        BookmarkablePageLink egitmenler =
                new BookmarkablePageLink("Egitmenler", TrainingPage.class, paramsEgitmen);
        markUpEgitmen.add(egitmenler);

        //add java programlama dili
        PageParameters paramsJavaTraining = new PageParameters();
        paramsJavaTraining.add("0", "java-programlama-dili-egitimi"); // java training page
        WebMarkupContainer markUpJPD = new WebMarkupContainer("MarkUpJPD");
        markUpJPD.setOutputMarkupId(true);
        BookmarkablePageLink javaProglamaDili =
                new BookmarkablePageLink("JPD", TrainingPage.class, paramsJavaTraining);
        markUpJPD.add(javaProglamaDili);


        // add nesneye yonelik programlama
        PageParameters paramsNesneyeYonelik = new PageParameters();
        paramsNesneyeYonelik.add("0", "nesneye-yonelik-tasarim-ve-tasarim-kaliplari-egitimi"); // nesneye yonelik
        WebMarkupContainer markUpNYT = new WebMarkupContainer("MarkUpNYT");
        markUpNYT.setOutputMarkupId(true);
        BookmarkablePageLink nesneyeYonelikTasarim =
                new BookmarkablePageLink("NYT", TrainingPage.class, paramsNesneyeYonelik);

        markUpNYT.add(nesneyeYonelikTasarim);


        // add apache wicket
        PageParameters paramsApacheWicket = new PageParameters();
        paramsApacheWicket.add("0", "apache-wicket-spring-egitimi"); // wicket yonelik
        WebMarkupContainer markUpAW = new WebMarkupContainer("MarkUpAW");
        markUpAW.setOutputMarkupId(true);
        BookmarkablePageLink apacheWicket =
                new BookmarkablePageLink("AW", TrainingPage.class, paramsApacheWicket);
        markUpAW.add(apacheWicket);

        // add google guice
        PageParameters paramsGoogleGuice = new PageParameters();
        paramsGoogleGuice.add("0", "google-guice-egitimi"); // google yonelik
        WebMarkupContainer markUpGG = new WebMarkupContainer("MarkUpGG");
        markUpGG.setOutputMarkupId(true);
        BookmarkablePageLink googleGuice =
                new BookmarkablePageLink("GG", TrainingPage.class, paramsGoogleGuice);
        markUpGG.add(googleGuice);


        if (params != null) {
            String previousSelection = "1000"; // go to default config
            try {
                previousSelection = params.getString("0");
            } catch (Exception ex) {
            }

            if (previousSelection.equalsIgnoreCase("java-egitimleri")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", "selected"));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            } else if (previousSelection.equalsIgnoreCase("kodcu-com-java-egitimlerine-kayit")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", "selected"));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            } else if (previousSelection.equalsIgnoreCase("java-programlama-dili-egitimi")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", "selected"));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            } else if (previousSelection.equalsIgnoreCase("nesneye-yonelik-tasarim-ve-tasarim-kaliplari-egitimi")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", "selected"));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            } else if (previousSelection.equalsIgnoreCase("apache-wicket-spring-egitimi")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", "selected"));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            } else if (previousSelection.equalsIgnoreCase("google-guice-egitimi")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", "selected"));
            } else if (previousSelection.equalsIgnoreCase("java-egitmenler")) {
                markUpBilgi.add(new SimpleAttributeModifier("class", ""));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", "selected"));
                markUpGG.add(new SimpleAttributeModifier("class", ""));

            } else {
                markUpBilgi.add(new SimpleAttributeModifier("class", "selected"));
                markUpKayit.add(new SimpleAttributeModifier("class", ""));
                markUpJPD.add(new SimpleAttributeModifier("class", ""));
                markUpNYT.add(new SimpleAttributeModifier("class", ""));
                markUpAW.add(new SimpleAttributeModifier("class", ""));
                markUpGG.add(new SimpleAttributeModifier("class", ""));
                markUpEgitmen.add(new SimpleAttributeModifier("class", ""));
            }


        }

        add(markUpBilgi);

        add(markUpEgitmen);

        add(markUpKayit);

        add(markUpJPD);

        add(markUpNYT);

        add(markUpAW);

        add(markUpGG);

    }

}
